import Network from './network'

// 注册
export const registerUser = (data: Object) => Network.post('/register', data)
// 发送邮箱验证码
export const emailCode = (email: string) => Network.get(`/emailcode?email=${email}`)
// 登录
export const loginUser = (data: Object) => Network.post('/login', data)


// 获取所有用户列表
export const getUsers = () => Network.get('/api/v1/users')
// 获取用户列表（关键字）
export const getUserPage = (data:Object) => Network.get('/api/v1/userpage',data)
// 获取单个用户信息
export const getOneUserInfo = (id:string) => Network.get(`/api/v1/users/${id}`)
// 添加用户
export const addUsers = (data:Object) => Network.post('/api/v1/users',data)
// 删除用户
export const delUsers = (id:string) => Network.delete(`/api/v1/users/${id}`)
// 编辑用户
export const updateUsers = (id:string,data:Object) => Network.put(`/api/v1/users/${id}`,data)


// 获取所有角色
export const getAllRoles = () => Network.get('/api/v1/allroles')
// 获取单个角色信息
export const getOneRoleInfo = (id:string) => Network.get(`/api/v1/roles/${id}`)
// 获取角色列表(带查询条件 页码等)
export const getRoles = (data:Object) => Network.get('/api/v1/roles',data)
// 新增角色
export const getAddRoles = (data:Object) => Network.post('/api/v1/roles',data)
// 删除角色
export const delRole = (id:string) => Network.delete(`/api/v1/roles/${id}`)
// 编辑用户
export const updateRoles = (id:string,data:Object) => Network.put(`/api/v1/roles/${id}`,data)

// 分配角色给用户
export const createUserRole = (data: Object) => Network.post('/api/v1/userrole', data)
// 删除用户角色
export const delUserRole = (userId:string,data:Object) => Network.delete(`/api/v1/userrole/${userId}`,data)

// 获取全部权限
export const getAllRights = () => Network.get('/api/v1/allrights')
// 获取权限列表(带查询条件 页码等)
export const getRights = (data:Object) => Network.get('/api/v1/rights',data)
// 获取单个权限信息
export const getRightInfo = (id:string) => Network.get(`/api/v1/rights/${id}`)
// 新增权限
export const getAddRights = (data:Object) => Network.post('/api/v1/rights',data)
// 删除权限
export const delRights = (id: string) => Network.delete(`/api/v1/rights/${id}`)
// 编辑权限
export const updateRights = (id:string,data:Object) => Network.put(`/api/v1/rights/${id}`,data)

// 给角色分配权限
export const createRoleRights = (data: Object) => Network.post(`/api/v1/roleRights`, data)
// 移除角色权限
export const delRoleRights = (roleId:string,data:Object) => Network.delete(`/api/v1/roleRights/${roleId}`,data)

export const text = () => Network.get('/test')
